/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.IOException;
import java.util.Objects;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import util.LoadLog4jProperties;

/**
 *
 * @author wxhntmy
 */
public class Main extends Application {
    
    @Override
    public void start(Stage stage) {
        try {
            //读取log4j日志配置文件
            LoadLog4jProperties.init();

            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/view/HomePageView.fxml"));
             Parent root = (Parent) fxmlLoader.load();
             Scene scene = new Scene(root);
             stage.setScene(scene);
             //设置窗口的图标
             stage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/images/b2.png"))));
             stage.setTitle("串口调试助手 V1.0    作者：wxhntmy    邮箱：wxhntmy@163.com");
             stage.show();
             //窗口关闭按钮事件，防止关闭程序时没有关闭串口，当关闭窗口时结束所有进程
             stage.setOnCloseRequest((WindowEvent event) -> {
                 System.exit(0);
             });
         } catch (IOException e) {
            e.printStackTrace();
         }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}

